package com.backend.service.impl;


import com.backend.pojo.entity.LeaveRequest;
import com.backend.pojo.vo.LeaveRequestVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.backend.service.examineService;
import com.backend.mapper.examineMapper;
import java.util.List;

@Service
public class examineServiceImpl implements examineService {
    @Autowired
    private examineMapper examineMapper;

    /*查询请假名单*/
    public List<LeaveRequestVO> getLeaves() {
        /*查询状态为未审批的请假名单*/
        List<LeaveRequestVO> list =  examineMapper.getLeaves();
        return list;
    }


    /*审核请假*/
    public void examineLeave(String stuId) {
       LeaveRequest leaveRequest = examineMapper.getLeavesById(stuId);
       leaveRequest.setStatus(1);
       examineMapper.updateStatus(leaveRequest);
    }

    /*根据id查询请假单详情*/
    public LeaveRequestVO getById(String stuId) {
        LeaveRequestVO  leaveRequestVO = examineMapper.getById(stuId);
        return leaveRequestVO;
    }

    /*根据学生id打回请假单*/
    public void sendBack(String stuId) {
        LeaveRequest leaveRequest = examineMapper.getLeavesById(stuId);
        leaveRequest.setStatus(2);
        examineMapper.updateStatus(leaveRequest);
    }

    /*根据学生id删除请假单*/
    public void deleteById(String stuId) {
        examineMapper.deleteById(stuId);
    }

    /*根据条件查询请假单信息*/
    public List<LeaveRequestVO> getByCondition(String condition) {
        List<LeaveRequestVO> list =  examineMapper.getByCondition(condition);
        return list;
    }





}
